<style type="text/css">
{literal}
	#content label {
		width: 300px;
		clear: left;
	}
	#content div.margin-form {
		padding-left: 320px;
	}
	#content input[type='text'][disabled] {
		background-color: #CCC;
		border-color: #999;
	}
{/literal}
</style>

<h2>{l s='Atos by TrogloGeek' mod='tgg_atos'}</h2>

{if count($errors)}
	<div class="alert error" style="width: auto">
    	<h3>{l s='There are some errors' mod='tgg_atos'}</h3>
        <ol>
        {foreach from=$errors item='error'}
        	<li class="bullet">{$error}</li>
        {/foreach}
        </ol>
    </div>
{/if}

<form action="{$smarty.server.REQUEST_URI}" enctype="multipart/form-data" method="post">
	<fieldset>
        <legend>{l s='Configuration' mod='tgg_atos'}</legend>
        <label for="field_bank">{l s='Bank server to use:' mod='tgg_atos'}&nbsp;</label>
        <div class="margin-form">
            <select name="bank" id="field_bank">
            {foreach from=$banks item='banktitle' key='bankname'}
                <option value="{$bankname}"{if $bank == $bankname} selected="selected"{/if}>{$banktitle|escape:'html':'UTF-8'}</option>
            {/foreach}
            </select>
        </div>
        <label for="field_demo">{l s='Mode:' mod='tgg_atos'}&nbsp;</label>
        <div class="margin-form">
            <select name="demo" id="field_demo" onchange="if ($(this).val() == '1') {ldelim}$('#production_conf:visible').hide('fast'){rdelim} else {ldelim}$('#production_conf:hidden').show('fast'){rdelim}">
            	<option value="1"{if $demo} selected="selected"{/if}>{l s='Demo/Test' mod='tgg_atos'}</option>
            	<option value="0"{if !$demo} selected="selected"{/if}>{l s='Production or pre-production' mod='tgg_atos'}</option>
            </select>
        </div>
        <div id="production_conf"{if $demo} style="display: none"{/if}>
            <label for="field_merchant_id">{l s='Merchant id to use:' mod='tgg_atos'}&nbsp;</label>
            <div class="margin-form">
                {if count($merchant_ids)}
                    <select name="merchant_id" id="field_merchant_id">
                    {foreach from=$merchant_ids item='mid'}
                        <option value="{$mid|escape:'htmlall':'UTF-8'}"{if $mid == $merchant_id} selected="selected"{/if}>{$mid|escape:'htmlall':'UTF-8'}</option>
                    {/foreach}
                    </select>
                {else}
                    <span style="position: relative; top: 0.2em">{l s='No production certificate found' mod='tgg_atos'}</span>
                {/if}
            </div>
            <label for="field_new_certificate">{l s='Upload a certificate:' mod='tgg_atos'}&nbsp;</label>
            <div class="margin-form">
                <input type="file" name="new_certificate" id="field_new_certificate" />
            </div>
        </div>
        <label for="field_logo_name">{l s='Merchant logo name:' mod='tgg_atos'}&nbsp;</label>
        <div class="margin-form">
            <input type="text" name="logo_name" id="field_logo_name" value="{$logo_name|escape:'htmlall':'UTF-8'}" />
        </div>
        <label for="field_fallback_currency">{l s='Fallback currency:' mod='tgg_atos'}&nbsp;</label>
        <div class="margin-form">
            <select name="fallback_currency" id="field_fallback_currency">
            	<option value=""></option>
                {foreach from=$currencies item='currency'}
	                <option value="{$currency.iso_code|escape:'htmlall':'UTF-8'}"{if $fallback_currency == $currency.iso_code} selected="selected"{/if}>{$currency.name|escape:'htmlall':'UTF-8'}&nbsp;{$currency.sign|escape:'htmlall':'UTF-8'}</option>
                {/foreach}
            </select>
        </div>
        <br />
		<br />

        {if !$display_advanced_conf}
        	<a href="javascript:;" onclick="$('#advanced_conf').show('fast'); $(this).hide();" style="font-weight: 600;">&gt;&nbsp;{l s='Display advanced configuration' mod='tgg_atos'}</a><br />
		{/if}
        <div id="advanced_conf"{if !$display_advanced_conf} style="display: none;{/if}">
        	<h3>{l s='Advanced configuration' mod='tgg_atos'}</h3>
            <label for="field_os_payment_success">{l s='Order state on payment success:' mod='tgg_atos'}&nbsp;</label>
            <div class="margin-form">
                <select name="os_payment_success" id="field_os_payment_success">
                    <option value=""></option>
                    {foreach from=$order_states item='order_state'}
                        <option value="{$order_state.id_order_state|escape:'htmlall':'UTF-8'}"{if $os_payment_success == $order_state.id_order_state} selected="selected"{/if}>{$order_state.name|escape:'htmlall':'UTF-8'}</option>
                    {/foreach}
                </select>
            </div>
            <label for="field_payment_means">{l s='Payment means accepted:' mod='tgg_atos'}&nbsp;</label>
            <div class="margin-form">
            	<input type="text" name="payment_means" id="field_payment_means" value="{$payment_means|escape:'htmlall':'UTF-8'}" style="width: 200px;" />
                <span class="hint">{l s='See documentation given by your bank' mod='tgg_atos'}</span>
            </div>
            <label for="field_bin_path">{l s='Binaries path (cgi-bin):' mod='tgg_atos'}&nbsp;</label>
            <div class="margin-form">
            	<br />
            	<label class="t clearfix"><input type="checkbox" name="bool_binaries_in_path" onclick="{literal}if ($(this).attr('checked')) {$('#field_bin_path').attr('disabled', 'disabled');} else {$('#field_bin_path').removeAttr('disabled');}{/literal}" value="1" {if $bool_binaries_in_path} checked="checked"{/if}/>&nbsp;{l s='My webserver holds them in his binaries path' mod='tgg_atos'}</label>
                <br />
				<br />
                <input type="text" name="bin_path" id="field_bin_path" value="{$bin_path|escape:'html':'UTF-8'}" style="width: 550px;" {if $bool_binaries_in_path}disabled="disabled" {/if}/>
            </div>
            <label for="field_param_path">{l s='Parameter files path:' mod='tgg_atos'}&nbsp;</label>
            <div class="margin-form">
                <input type="text" name="param_path" id="field_param_path" value="{$param_path|escape:'html':'UTF-8'}" style="width: 550px;" />
                <span class="hint">{l s='54 characters maximum' mod='tgg_atos'}</span>
            </div>
            <label for="field_log_path">{l s='Logfiles path:' mod='tgg_atos'}&nbsp;</label>
            <div class="margin-form">
                <input type="text" name="log_path" id="field_log_path" value="{$log_path|escape:'html':'UTF-8'}" style="width: 550px;" />
            </div>
            <label for="field_logo_path">{l s='Cards logos path:' mod='tgg_atos'}&nbsp;</label>
            <div class="margin-form">
                <input type="text" name="logo_path" id="field_logo_path" value="{$logo_path|escape:'html':'UTF-8'}" style="width: 550px;" />
            </div>
            <label for="field_img_path">{l s='Banks logos path:' mod='tgg_atos'}&nbsp;</label>
            <div class="margin-form">
                <input type="text" name="img_path" id="field_img_path" value="{$img_path|escape:'html':'UTF-8'}" style="width: 550px;" />
            </div>
            <label>{l s='Log responses' mod='tgg_atos'}&nbsp;</label>
            <div class="margin-form clearfix">
            	<br />
                <label class="t"><input type="checkbox" name="bool_response_log_txt" value="1" {if $bool_response_log_txt} checked="checked"{/if}/>&nbsp;{l s='TXT format' mod='tgg_atos'}</label>
                <br />
                <br />
				<label class="t"><input type="checkbox" name="bool_response_log_csv" value="1" {if $bool_response_log_csv} checked="checked"{/if}/>&nbsp;{l s='CSV format' mod='tgg_atos'}&nbsp;(PHP 5 >= 5.1.0)</label>
            </div>
            <label for="field_int_min_tid">{l s='Start transaction IDs at:' mod='tgg_atos'}&nbsp;</label>
            <div class="margin-form">
                <input type="text" name="int_min_tid" id="field_int_min_tid" value="{$int_min_tid|escape:'html':'UTF-8'}" style="width: 60px;" />
                <span class="hint">{l s='Maximum ID autorized by Atos is 999999, keep in mind that higher is the minimum ID you choose, lesser you will be able to offer payments by Atos a day. Must be at least 1.' mod='tgg_atos'}</span>
            </div>
        </div>
        <br />
        <div class="margin-form">
            <input type="submit" name="updateConf" class="button" />
            <br /><br />
            <input type="submit" name="defaultConf" class="button" value="{l s='Restore default configuration' mod='tgg_atos'}" />
       </div>
    </fieldset>
</form>
